import os
from datetime import timedelta


class Config:
    """基础配置"""
    # Flask配置
    # SECRET_KEY =  'f69a3e2c97b8ed2d8855fa9bf4d4c50d2ac00958ffed181ea8d8ab6ed57a5a3a'
    # SQLALCHEMY_DATABASE_URI = "mysql://root:wyq123.@localhost:3306/online_exam_system"
    # # 数据库配置
    # MYSQL_HOST = os.environ.get('MYSQL_HOST') or 'localhost'
    # MYSQL_PORT = int(os.environ.get('MYSQL_PORT') or 3306)
    # MYSQL_USER = os.environ.get('MYSQL_USER') or 'root'
    # MYSQL_PASSWORD = os.environ.get('MYSQL_PASSWORD') or 'wyq12345.'
    # MYSQL_DB = os.environ.get('MYSQL_DB') or 'Online_exam_system'
    # MYSQL_CHARSET = 'utf8mb4'
    #
    # SQLALCHEMY_DATABASE_URI = f'mysql+pymysql://{MYSQL_USER}:{MYSQL_PASSWORD}@{MYSQL_HOST}:{MYSQL_PORT}/{MYSQL_DB}?charset={MYSQL_CHARSET}'
    # SQLALCHEMY_TRACK_MODIFICATIONS = False
    # SQLALCHEMY_ECHO = False

    SQLALCHEMY_DATABASE_URI = "mysql://root:123456@localhost:3306/online_exam_system"
    # 文件上传配置
    MAX_CONTENT_LENGTH = 16 * 1024 * 1024  # 16MB
    UPLOAD_FOLDER = 'uploads'

    # 会话配置
    PERMANENT_SESSION_LIFETIME = timedelta(hours=2)

    # 日志配置
    LOG_DIR = 'logs'
    LOG_LEVEL = 'INFO'



    # Redis配置（用于Celery）
    REDIS_URL = os.environ.get('REDIS_URL') or 'redis://localhost:6379/0'

    # 为未来多学校扩展预留
    CURRENT_SCHOOL_ID = 1


class DevelopmentConfig(Config):
    """开发环境配置"""
    DEBUG = True
    SQLALCHEMY_ECHO = True


class ProductionConfig(Config):
    """生产环境配置"""
    DEBUG = False


config = {
    'development': DevelopmentConfig,
    'production': ProductionConfig,
    'default': DevelopmentConfig
}